#ifndef PAGINATIONCONTROLLER_H
#define PAGINATIONCONTROLLER_H

#include <QObject>

class DatabaseManager;

class PaginationController : public QObject
{
    Q_OBJECT
public:
    explicit PaginationController(DatabaseManager *databaseManager, QObject *parent = nullptr);

    // 设置分页
    void setupPagination(int totalRecords, int pageSize = 5);

    // 属性
    int currentPage();
    int totalPages();



    int pageSize();

    int Records();

public slots:
    void gotoPage(int page);// 跳转到指定页
    void nextPage();    // 下一页
    void prevPage();    // 上一页
    void firstPage();   // 首页
    void lastPage();    // 尾页

    void setCurrentPage(int currentPage);

signals:
    void pageChanged(int newPage);
    void paginationUpdated(int current, int total);

private:
    int m_currentPage = 1;
    int m_totalPages = 1;
    int m_Records = 0;
    int m_pageSize = 10;

    DatabaseManager *m_databaseManager;
};

#endif // PAGINATIONCONTROLLER_H
